import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        //在歌手列表页和详情页两个页面(组件)共享歌手的信息
        singer: {}
    },
    mutations: {
        saveSinger(state, s) {   //s(singer)
            state.singer = s
        }
    },
    actions: {
        saveSinger(context, singer) {
            //提交(commit)mutations
            context.commit("saveSinger", singer)
        }
    }
})
export default store